package com.ruoyi.service.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.service.domain.ServiceRole;
import com.ruoyi.service.service.IServiceRoleService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 护士角色表Controller
 * 
 * @author ZDL
 * @date 2024-11-12
 */
@RestController
@RequestMapping("/service/role")
public class ServiceRoleController extends BaseController
{
    @Autowired
    private IServiceRoleService serviceRoleService;

    /**
     * 查询护士角色表列表
     */
    @PreAuthorize("@ss.hasPermi('service:role:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceRole serviceRole)
    {
        startPage();
        List<ServiceRole> list = serviceRoleService.selectServiceRoleList(serviceRole);
        return getDataTable(list);
    }

    /**
     * 导出护士角色表列表
     */
    @PreAuthorize("@ss.hasPermi('service:role:export')")
    @Log(title = "护士角色表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceRole serviceRole)
    {
        List<ServiceRole> list = serviceRoleService.selectServiceRoleList(serviceRole);
        ExcelUtil<ServiceRole> util = new ExcelUtil<ServiceRole>(ServiceRole.class);
        util.exportExcel(response, list, "护士角色表数据");
    }

    /**
     * 获取护士角色表详细信息
     */
    @PreAuthorize("@ss.hasPermi('service:role:query')")
    @GetMapping(value = "/{roleId}")
    public AjaxResult getInfo(@PathVariable("roleId") Long roleId)
    {
        return success(serviceRoleService.selectServiceRoleByRoleId(roleId));
    }

    /**
     * 新增护士角色表
     */
    @PreAuthorize("@ss.hasPermi('service:role:add')")
    @Log(title = "护士角色表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceRole serviceRole)
    {
        return toAjax(serviceRoleService.insertServiceRole(serviceRole));
    }

    /**
     * 修改护士角色表
     */
    @PreAuthorize("@ss.hasPermi('service:role:edit')")
    @Log(title = "护士角色表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceRole serviceRole)
    {
        return toAjax(serviceRoleService.updateServiceRole(serviceRole));
    }

    /**
     * 删除护士角色表
     */
    @PreAuthorize("@ss.hasPermi('service:role:remove')")
    @Log(title = "护士角色表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{roleIds}")
    public AjaxResult remove(@PathVariable Long[] roleIds)
    {
        return toAjax(serviceRoleService.deleteServiceRoleByRoleIds(roleIds));
    }
}
